import React, { Component } from 'react'
import store from './redux/store.js'
import { increment, decrement } from './redux/action.js'

class App extends Component {
    addEvent = () => {
        store.dispatch(increment(2))
    }
    deceEvent = () => {
        store.dispatch(decrement(3))
    }
    componentDidMount() {
        store.subscribe(() => {
            this.setState({})
        })
    }
    render() {
        const { num } = store.getState();
        return (
            <div className="container">
				<h4 className='display-4'>当前值为 {num}</h4>
				<button onClick={this.addEvent} className="mr-2 btn btn-primary">增加</button>
				<button onClick={this.deceEvent} className="btn btn-danger">减少</button>
			</div>
        )
    }
}

export default App